<!DOCTYPE HTML>
<html lang="en" >
    <!-- Start book 个人笔记 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>DOM的增、删、改、查 | 个人笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../md/javascript/数组.html" />
    
    
    <link rel="prev" href="../../md/javascript/Date.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="3.4"
        data-chapter-title="DOM的增、删、改、查"
        data-filepath="md/javascript/document的使用.md"
        data-basepath="../.."
        data-revision="Thu Feb 14 2019 20:54:34 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        开始界面
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/html/jianjie.html">
            
                
                    <a href="../../md/html/jianjie.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        html
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="md/html/20170719.html">
            
                
                    <a href="../../md/html/20170719.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        head
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="md/html/2017720.html">
            
                
                    <a href="../../md/html/2017720.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        常用标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="md/html/sy.html">
            
                
                    <a href="../../md/html/sy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        音频与视频
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="md/html/ckw.html">
            
                
                    <a href="../../md/html/ckw.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        实体字符与锚点
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="md/html/table.html">
            
                
                    <a href="../../md/html/table.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        table表格
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="md/html/input.html">
            
                
                    <a href="../../md/html/input.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        input标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="md/html/form.html">
            
                
                    <a href="../../md/html/form.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        form表单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="md/html/buju.html">
            
                
                    <a href="../../md/html/buju.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        网页布局
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/css/css.html">
            
                
                    <a href="../../md/css/css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="md/css/20170724.html">
            
                
                    <a href="../../md/css/20170724.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        选择器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="md/css/通配选择器.html">
            
                
                    <a href="../../md/css/通配选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.1.</b>
                        
                        通配选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="md/css/元素选择器.html">
            
                
                    <a href="../../md/css/元素选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.2.</b>
                        
                        元素选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="md/css/群组选择器.html">
            
                
                    <a href="../../md/css/群组选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.3.</b>
                        
                        群组选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="md/css/关系选择器.html">
            
                
                    <a href="../../md/css/关系选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.4.</b>
                        
                        关系选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="md/css/id和class选择器.html">
            
                
                    <a href="../../md/css/id和class选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.5.</b>
                        
                        id和class选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="md/css/weilei.html">
            
                
                    <a href="../../md/css/weilei.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.6.</b>
                        
                        伪类选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="md/css/属性选择器.html">
            
                
                    <a href="../../md/css/属性选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.7.</b>
                        
                        属性选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="md/css/伪对象选择器.html">
            
                
                    <a href="../../md/css/伪对象选择器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.8.</b>
                        
                        伪对象选择器
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="md/css/字体.html">
            
                
                    <a href="../../md/css/字体.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        字体库的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="md/css/边框.html">
            
                
                    <a href="../../md/css/边框.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        border边框和background背景
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="md/css/浮动.html">
            
                
                    <a href="../../md/css/浮动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="md/css/块级和行内.html">
            
                
                    <a href="../../md/css/块级和行内.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        块级和行内元素
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="md/css/盒子.html">
            
                
                    <a href="../../md/css/盒子.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        盒子模型和三角形
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="md/css/聊天气泡.html">
            
                
                    <a href="../../md/css/聊天气泡.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        聊天气泡
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="md/css/段落控制.html">
            
                
                    <a href="../../md/css/段落控制.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        文字溢出处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="md/css/固定定位.html">
            
                
                    <a href="../../md/css/固定定位.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        定位
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="md/css/sacss.html">
            
                
                    <a href="../../md/css/sacss.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        sacss和码云git的使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="md/css/sacss的安装.html">
            
                
                    <a href="../../md/css/sacss的安装.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.1.</b>
                        
                        sacss的安装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="md/css/sacss使用.html">
            
                
                    <a href="../../md/css/sacss使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.2.</b>
                        
                        sacss的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="md/css/码云.html">
            
                
                    <a href="../../md/css/码云.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.3.</b>
                        
                        码云
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="md/css/变换和过渡.html">
            
                
                    <a href="../../md/css/变换和过渡.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.11.</b>
                        
                        transform变换和transition过渡
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="md/css/swiper的使用.html">
            
                
                    <a href="../../md/css/swiper的使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.12.</b>
                        
                        swiper的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="md/css/viewport视口.html">
            
                
                    <a href="../../md/css/viewport视口.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.13.</b>
                        
                        viewport视口
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="md/css/列式布局.html">
            
                
                    <a href="../../md/css/列式布局.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.14.</b>
                        
                        列式布局
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.15" data-path="md/css/媒体查询.html">
            
                
                    <a href="../../md/css/媒体查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.15.</b>
                        
                        媒体查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.16" data-path="md/css/flex弹性盒子.html">
            
                
                    <a href="../../md/css/flex弹性盒子.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.16.</b>
                        
                        flex弹性盒子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/javascript/javascript.html">
            
                
                    <a href="../../md/javascript/javascript.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        javascript
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="md/javascript/类型.html">
            
                
                    <a href="../../md/javascript/类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        类型与语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="md/javascript/定时器.html">
            
                
                    <a href="../../md/javascript/定时器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        定时器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="md/javascript/Date.html">
            
                
                    <a href="../../md/javascript/Date.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        Date时间、日期
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="3.4" data-path="md/javascript/document的使用.html">
            
                
                    <a href="../../md/javascript/document的使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        DOM的增、删、改、查
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="md/javascript/数组.html">
            
                
                    <a href="../../md/javascript/数组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        数组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="md/javascript/for循环.html">
            
                
                    <a href="../../md/javascript/for循环.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        for循环
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="md/javascript/Math对象.html">
            
                
                    <a href="../../md/javascript/Math对象.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        Math对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="md/javascript/事件.html">
            
                
                    <a href="../../md/javascript/事件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        事件
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="md/javascript/事件监听器.html">
            
                
                    <a href="../../md/javascript/事件监听器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.1.</b>
                        
                        事件监听器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="md/javascript/滚动条事件.html">
            
                
                    <a href="../../md/javascript/滚动条事件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.2.</b>
                        
                        滚动条事件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8.3" data-path="md/javascript/事件代理.html">
            
                
                    <a href="../../md/javascript/事件代理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.3.</b>
                        
                        事件代理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8.4" data-path="md/javascript/事件派发.html">
            
                
                    <a href="../../md/javascript/事件派发.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.4.</b>
                        
                        事件派发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8.5" data-path="md/javascript/鼠标跟随事件.html">
            
                
                    <a href="../../md/javascript/鼠标跟随事件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.5.</b>
                        
                        鼠标跟随事件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8.6" data-path="md/javascript/鼠标事件.html">
            
                
                    <a href="../../md/javascript/鼠标事件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.6.</b>
                        
                        鼠标、键盘事件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="md/javascript/对象.html">
            
                
                    <a href="../../md/javascript/对象.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="md/javascript/轮播图.html">
            
                
                    <a href="../../md/javascript/轮播图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        轮播图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="md/javascript/高德地图的使用.html">
            
                
                    <a href="../../md/javascript/高德地图的使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.11.</b>
                        
                        高德地图的使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="md/javascript/预加载.html">
            
                
                    <a href="../../md/javascript/预加载.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.12.</b>
                        
                        预加载
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.13" data-path="md/javascript/vue框架.html">
            
                
                    <a href="../../md/javascript/vue框架.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.13.</b>
                        
                        vue框架
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.14" data-path="md/javascript/http缓存.html">
            
                
                    <a href="../../md/javascript/http缓存.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.14.</b>
                        
                        http缓存
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.15" data-path="md/javascript/闭包.html">
            
                
                    <a href="../../md/javascript/闭包.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.15.</b>
                        
                        闭包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.16" data-path="md/javascript/Ajax.html">
            
                
                    <a href="../../md/javascript/Ajax.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.16.</b>
                        
                        Ajax
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.17" data-path="md/javascript/Ajax数据请求.html">
            
                
                    <a href="../../md/javascript/Ajax数据请求.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.17.</b>
                        
                        Ajax数据请求
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.18" data-path="md/javascript/打包工具.html">
            
                
                    <a href="../../md/javascript/打包工具.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.18.</b>
                        
                        打包工具
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.19" data-path="md/javascript/前端框架汇总.html">
            
                
                    <a href="../../md/javascript/前端框架汇总.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.19.</b>
                        
                        前端框架汇总
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="md/jquery/jquery.html">
            
                
                    <a href="../../md/jquery/jquery.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        jquery
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5" data-path="md/book/book.html">
            
                
                    <a href="../../md/book/book.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        弹性盒子
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6" data-path="md/tool/前端工具.html">
            
                
                    <a href="../../md/tool/前端工具.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        前端工具
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="md/tool/git的安装.html">
            
                
                    <a href="../../md/tool/git的安装.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        git的安装
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="md/opus/item.html">
            
                
                    <a href="../../md/opus/item.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        项目
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >个人笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="dom-document-object-model&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;">DOM (Document Object Model)&#x6587;&#x6863;&#x5BF9;&#x8C61;&#x6A21;&#x578B;</h1>
<p><strong>&#x6CE8;&#x610F;&#xFF1A;</strong>&#x6DFB;&#x52A0;&#x5230;&#x9875;&#x9762;&#x4E0A;&#x7684;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x7A0B;&#x5E8F;&#x6570;&#x91CF;&#x5C06;&#x76F4;&#x63A5;&#x5173;&#x7CFB;&#x5230;&#x9875;&#x9762;&#x7684;&#x6574;&#x4F53;&#x8FD0;&#x884C;&#x6027;&#x80FD;&#xFF0C;&#x56E0;&#x4E3A;&#x9700;&#x8981;&#x4E0D;&#x65AD;&#x7684;&#x4E0E;dom&#x8282;&#x70B9;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#xFF0C;&#x8BBF;&#x95EE;dom&#x7684;&#x6B21;&#x6570;&#x8D8A;&#x591A;&#xFF0C;
&#x5F15;&#x8D77;&#x6D4F;&#x89C8;&#x5668;&#x91CD;&#x7ED8;&#x4E0E;&#x91CD;&#x6392;&#x7684;&#x6B21;&#x6570;&#x4E5F;&#x5C31;&#x8D8A;&#x591A;&#xFF0C;&#x5C31;&#x4F1A;&#x5EF6;&#x957F;&#x6574;&#x4E2A;&#x9875;&#x9762;&#x7684;&#x4EA4;&#x4E92;&#x5C31;&#x7EEA;&#x65F6;&#x95F4;</p>
<h2 id="dom&#x7684;&#x589E;">DOM&#x7684;&#x589E;</h2>
<pre><code>&lt;ul&gt;
    &lt;li&gt;01&lt;/li&gt;
    &lt;li&gt;02&lt;/li&gt;
    &lt;li&gt;03&lt;/li&gt;
    &lt;li&gt;04&lt;/li&gt;
    &lt;li&gt;05&lt;/li&gt;
&lt;/ul&gt;
</code></pre><p>1.&#x521B;&#x5EFA;&#x5143;&#x7D20;</p>
<pre><code>var li_06 = document.createElement(&apos;li&apos;);
//createElement(&quot;&#x6807;&#x7B7E;&#x540D;&quot;)
</code></pre><p>2.&#x5728;&#x961F;&#x5C3E;&#x6DFB;&#x52A0;<br>
<code>Node.appendChild(new_child)</code>&#x5728;<code>Node</code>&#x91CC;&#x7684;&#x5B69;&#x5B50;&#x7684;&#x961F;&#x5C3E;&#x6DFB;&#x52A0;<code>new_child</code></p>
<pre><code>//children&#x662F;&#x4E00;&#x4E2A;&#x53EA;&#x8BFB;&#x5C5E;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x5217;&#x4E3E;&#x51FA;&#x5143;&#x7D20;&#x91CC;&#x9762;&#x7684;&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;&#x4E0B;&#x9762;&#x7684;ul.children&#xFF0C;&#x5217;&#x4E3E;&#x51FA;ul&#x91CC;&#x9762;&#x7684;li
var child = ul.children;
console.log(child);

ul.appendChild( li_06 );
</code></pre><p><code>Node.insertBefore(new_child,position)</code>
 &#x5728;Node&#x91CC;&#x7684;&#x5B69;&#x5B50;&#x7684;position(&#x5143;&#x7D20;)&#x4E4B;&#x524D;&#x6DFB;&#x52A0;new_child</p>
<p> &#x9700;&#x8981;&#x6DFB;&#x52A0;&#x5230;&#x961F;&#x5C3E;&#x6700;&#x540E;position&#x4E3A;null&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;&#x4F8B;&#x5982;&#xFF1A;<code>ul.insertBefore(li_06,null);</code></p>
<p>3.&#x589E;&#x52A0;&#x6587;&#x672C;</p>
<pre><code>//innerHTML    &#x53EA;&#x6539;&#x53D8;&#x6807;&#x7B7E;&#x5185;&#x7684;&#x5185;&#x5BB9;&#x3002;outerHTML    &#x6539;&#x53D8;&#x6807;&#x7B7E;&#x548C;&#x5185;&#x5BB9;
li_06.innerHTML = &quot;5555&quot;;
li_06.outerHTML = &quot;5555&quot;;
li_06.innerText = &quot;5555&quot;;
li_06.textContent = &quot;5555&quot;;
</code></pre><p>4.&#x514B;&#x9686;</p>
<pre><code>var li_06 = li[2].cloneNode(true);
ul.appendChild(li_06);
</code></pre><p><strong>&#x6CE8;&#x91CA;&#xFF1A;</strong>&#x514B;&#x9686;&#x8282;&#x70B9;&#xFF0C;&#x9ED8;&#x8BA4;false&#x53EA;&#x514B;&#x9686;&#x6807;&#x7B7E;&#xFF1B;true&#x6DF1;&#x5EA6;&#x514B;&#x9686;&#xFF0C;&#x514B;&#x9686;&#x6807;&#x7B7E;&#x548C;&#x6807;&#x7B7E;&#x91CC;&#x7684;&#x5185;&#x5BB9;</p>
<h2 id="dom&#x7684;&#x5220;&#x9664;">DOM&#x7684;&#x5220;&#x9664;</h2>
<p>1.&#x79FB;&#x9664;&#x5B50;&#x5143;&#x7D20;&#x3002;</p>
<pre><code>ul.removeChild(li[5]);
</code></pre><p><strong>&#x8865;&#x5145;&#xFF1A;</strong><code>arr=[1,2,3,4,5];  arr.length = 4;</code>&#xFF0C;&#x5373;&#x539F;&#x672C;&#x957F;&#x5EA6;&#x4E3A;5&#xFF0C;&#x4F46;&#x6539;&#x53D8;&#x5176;&#x957F;&#x5EA6;&#xFF0C;&#x4ECE;&#x800C;&#x8FBE;&#x5230;&#x5220;&#x9664;&#x7684;&#x6548;&#x679C;&#xFF0C;&#x4F46;&#x53EA;&#x5BF9;&#x6570;&#x7EC4;&#x8D77;&#x4F5C;&#x7528;<br>
2.&#x79FB;&#x9664;&#x81EA;&#x8EAB;</p>
<pre><code>li[5].remove();
</code></pre><p><strong>&#x8865;&#x5145;&#xFF1A;</strong></p>
<pre><code>var body = document.getElementsByTagName(&quot;body&quot;);
var body = document.body;//&#x56E0;&#x4E3A;body&#x5177;&#x6709;&#x552F;&#x4E00;&#x6027;&#xFF0C;&#x6240;&#x4EE5;&#x53EA;&#x8981;&#x8FD9;&#x4E48;&#x5199;&#x4E5F;&#x80FD;&#x627E;&#x5230;body
console.log(body);
</code></pre><h2 id="dom&#x7684;&#x67E5;">DOM&#x7684;&#x67E5;</h2>
<p>HTML&#x4EE3;&#x7801;</p>
<pre><code>&lt;ul id=&quot;ul_id&quot; class=&quot;ul_className&quot;&gt;
    &lt;li id=&quot;li_id&quot; class=&quot;li_class&quot;&gt;01&lt;/li&gt;
    &lt;li class=&quot;li_class&quot; data-number=&quot;02&quot;&gt;02 &lt;p&gt;&#x8FD9;&#x91CC;&#x662F;p&#x6807;&#x7B7E;&lt;/p&gt;&lt;/li&gt;
    &lt;li class=&quot;li_class&quot;&gt;03&lt;/li&gt;
    &lt;li class=&quot;li_class&quot;&gt;04&lt;/li&gt;
    &lt;li class=&quot;li_class&quot;&gt;05&lt;/li&gt;
&lt;/ul&gt;
</code></pre><p>1.&#x6839;&#x636E;id&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x5BF9;&#x8C61;(&#x4E00;&#x4E2A;)</p>
<pre><code>var ul_id = document.getElementById(&apos;ul_id&apos;);
console.log(ul_id);
</code></pre><p>2.&#x6839;&#x636E;class&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x5BF9;&#x8C61;(&#x4E00;&#x5230;&#x591A;&#x4E2A;) &#x8FD4;&#x56DE;&#x7C7B;&#x6570;&#x7EC4;</p>
<pre><code>var ul_class = document.getElementsByClassName(&quot;ul_className&quot;);
console.log(ul_class);
</code></pre><p>3.&#x6839;&#x636E;&#x6807;&#x7B7E;&#x540D;&#x83B7;&#x53D6;&#x5143;&#x7D20;&#x5BF9;&#x8C61;(&#x4E00;&#x5230;&#x591A;&#x4E2A;)  &#x8FD4;&#x56DE;&#x7C7B;&#x6570;&#x7EC4;</p>
<pre><code>var li_tag = document.getElementsByTagName(&quot;li&quot;);
console.log(li_tag);
</code></pre><p>4.&#x53EA;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x5BF9;&#x8C61;</p>
<pre><code>var li_id = document.querySelector(&apos;#li_id&apos;);
console.log(li_id);
</code></pre><p>5.&#x8FD4;&#x56DE;&#x6240;&#x6709;&#x5339;&#x914D;&#x7684;&#x5143;&#x7D20;&#x5BF9;&#x8C61;</p>
<pre><code>var li_class = document.querySelectorAll(&apos;.li_class&apos;);
console.log(li_class);
</code></pre><p>6.&#x53EF;&#x4EE5;&#x5728;&#x5143;&#x7D20;&#x5BF9;&#x8C61;&#x4E2D;&#x627E;&#x5230;&#x8BE5;&#x5BF9;&#x8C61;&#x5305;&#x542B;&#x7684;&#x5143;&#x7D20;</p>
<pre><code>var li_02 = ul_id.getElementsByTagName(&quot;li&quot;)[1];
var p = li_02.getElementsByTagName(&quot;p&quot;)[0];
console.log(p);
</code></pre><p>7.&#x4E0B;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x5BF9;&#x8C61;(&#x5144;&#x5F1F;)</p>
<pre><code>var li_03 = li_02.nextSibling;//&#x5982;&#x679C;&#x6709;&#x7A7A;&#x683C;&#x6216;&#x6362;&#x884C;&#x7684;&#x8BDD;&#x5C31;&#x4F1A;&#x8F93;&#x51FA;#text
var li_03 = li_02.nextElementSibling;
console.log(li_03);
</code></pre><p>8.&#x4E0A;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x5BF9;&#x8C61;(&#x5144;&#x5F1F;)</p>
<pre><code>var li_01 = li_02.previousElementSibling;
console.log(li_01);
</code></pre><p>9.&#x6240;&#x6709;&#x5B50;&#x5143;&#x7D20;</p>
<pre><code>var li_all = ul_id.children;
console.log(li_all);
</code></pre><p>10.&#x627E;&#x7236;&#x5143;&#x7D20;</p>
<pre><code>var li_baba = li_01.parentNode;
console.log(li_baba);
</code></pre><h2 id="dom&#x7684;&#x6539;">DOM&#x7684;&#x6539;</h2>
<p>DOM&#x7684;&#x4FEE;&#x6539;&#x5C31;&#x662F;&#x4FEE;&#x6539;&#x6837;&#x5F0F;&#xFF0C;&#x4F46;&#x53EA;&#x80FD;&#x5728;html&#x7684;&#x884C;&#x5185;&#x4FEE;&#x6539;
HTML&#x4EE3;&#x7801;</p>
<pre><code>&lt;div class=&quot;baba baba1&quot;&gt;
    &lt;div class=&quot;son1&quot;&gt;

    &lt;/div&gt;
&lt;/div&gt;
</code></pre><p>1.&#x8BBE;&#x7F6E;</p>
<pre><code>var baba = document.querySelector(&quot;.baba&quot;);
var son1 = document.querySelector(&quot;.son1&quot;);

son1.setAttribute(&quot;style&quot;,&quot;width: 150px;&quot;);
son1.setAttribute(&quot;id&quot;,&quot;son&quot;);
/******************************/
//&#x4FEE;&#x6539;&#x8FC7;&#x540E;
&lt;div class=&quot;baba baba1&quot;&gt;
    &lt;div class=&quot;son1&quot; style=&quot;width:150px;&quot; id=&quot;son&quot;&gt;

    &lt;/div&gt;
&lt;/div&gt;
</code></pre><p>2.&#x83B7;&#x53D6;</p>
<pre><code>son1.getAttribute(&quot;class&quot;);
console.log(son1);
</code></pre><p><strong>&#x6CE8;&#x91CA;&#xFF1A;</strong>&#x83B7;&#x53D6;&#x7684;&#x662F;son1&#x91CC;&#x7684;class&#x7C7B;&#x7684;&#x5185;&#x5BB9;&#x3002;</p>
<p>3.&#x79FB;&#x9664;
<code>son1.removeAttribute(&quot;id&quot;);</code>&#x79FB;&#x9664;&#x7684;&#x91CC;&#x9762;&#x7684;id&#x5C5E;&#x6027;
//&#x79FB;&#x9664;&#x8FC7;&#x540E;</p>
<pre><code>&lt;div class=&quot;baba baba1&quot;&gt;
    &lt;div class=&quot;son1&quot; style=&quot;width:150px;&quot;&gt;

    &lt;/div&gt;
&lt;/div&gt;
</code></pre><p>4.&#x6DFB;&#x52A0;style&#x6837;&#x5F0F;</p>
<pre><code>//&#x7B2C;&#x4E00;&#x79CD;&#x5199;&#x6CD5;&#xFF0C;style.&#x6837;&#x5F0F;&#x5C5E;&#x6027; = &#x5C5E;&#x6027;&#x503C;
baba.style.backgroundColor = &quot;red&quot;;
baba.style.height = &quot;400px&quot;;

//&#x7B2C;&#x4E8C;&#x79CD;&#x5199;&#x6CD5;&#xFF0C;.style.cssText = &quot;&#x5C5E;&#x6027;&#x6837;&#x5F0F;&#xFF1A;&#x5C5E;&#x6027;&#x503C;;&quot;
var str = &quot;width:500px;&quot;+&quot;height: 500px;background: skyblue;&quot;
baba.style.cssText = str;
//baba.style.cssText = &quot;width:500px;&quot;;
</code></pre><p>5.&#x83B7;&#x53D6;&#x884C;&#x5185;&#x6837;&#x5F0F;</p>
<pre><code>//&#x7528;style&#x8FD9;&#x4E9B;&#x65B9;&#x6CD5;&#x83B7;&#x53D6;&#x6837;&#x5F0F;&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x53EA;&#x80FD;&#x83B7;&#x53D6;&#x884C;&#x5185;&#x6837;&#x5F0F;
var baba_width = baba.style.width;//&#x67E5;&#x770B;&#x5C5E;&#x6027;&#x72B6;&#x6001;
console.log(baba_width);
</code></pre><p>6.&#x6837;&#x5F0F;&#x8BA1;&#x7B97;&#x5C5E;&#x6027;(&#x53EA;&#x8BFB;)</p>
<pre><code>var baba_style = window.getComputedStyle(baba);
//console.log(baba_style.backgroundColor);
//console.log(baba_style);
</code></pre><p>7.class&#x7684;&#x589E;&#x3001;&#x5220;</p>
<pre><code>//&#x83B7;&#x53D6;baba&#x91CC;&#x7684;class&#x5C5E;&#x6027;&#x503C;
var baba_className = baba.className;
console.log(baba_className);

//&#x6DFB;&#x52A0;class&#x5C5E;&#x6027;&#x503C;Baba
baba.className = &quot;Baba&quot;;
console.log(baba_className);
</code></pre><p><strong>&#x6CE8;&#x610F;&#xFF1A;</strong>&#x540E;&#x9762;&#x7684;&#x5BB9;&#x6613;&#x8986;&#x76D6;&#x4E4B;&#x524D;&#x7684;&#x6570;&#x636E;&#x3002;&#x4F8B;&#x5982;&#xFF1A;&#x4E0A;&#x9762;&#x7684;&#x4E2D;&#x6700;&#x540E;&#x5C31;&#x53EA;&#x663E;&#x793A;&#x5C5E;&#x6027;&#x503C;Baba</p>
<p>8.&#x63A7;&#x5236;class
<strong>classList(&#x7C7B;&#x540D;&#x5217;&#x8868;):</strong>&#x628A;&#x7C7B;&#x91CC;&#x6240;&#x6709;&#x7684;&#x5C5E;&#x6027;&#x503C;&#x5217;&#x4E3E;&#x51FA;&#x6765;</p>
<pre><code>var baba_cl = baba.classList;
console.log(&quot;&#x589E;&#x52A0;&#x5217;&#x8868;&#xFF1A;&quot;+baba_cl)
</code></pre><p><strong>&#x589E;&#x52A0;class</strong></p>
<pre><code>baba.classList.add(&quot;active&quot;);
</code></pre><p><strong>&#x79FB;&#x9664;class</strong></p>
<pre><code>baba.classList.remove(&quot;baba1&quot;);
</code></pre><p><strong>&#x5207;&#x6362;class</strong></p>
<pre><code>baba.classList.toggle(&quot;baba&quot;);
console.log(baba_cl);
</code></pre><p><strong>&#x5207;&#x6362;class&#x7684;&#x8FD0;&#x7528;</strong></p>
<pre><code>&lt;button onclick=&quot;t()&quot;&gt;&#x5207;&#x6362;&#x80CC;&#x666F;&#x989C;&#x8272;&lt;/button&gt;
&lt;ul&gt;
    &lt;li&gt;01&lt;/li&gt;
    &lt;li&gt;02&lt;/li&gt;
    &lt;li&gt;03&lt;/li&gt;
    &lt;li&gt;04&lt;/li&gt;
    &lt;li&gt;05&lt;/li&gt;
&lt;/ul&gt;
</code></pre><pre><code>function t(){
    var li = document.getElementsByTagName(&quot;li&quot;);
    for(var i=0;i&lt;=li.length;i++){
        if(i%2==0){
            li[i].classList.toggle(&quot;red&quot;);
        }
    }
}
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/javascript/Date.html" class="navigation navigation-prev " aria-label="Previous page: Date时间、日期"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../md/javascript/数组.html" class="navigation navigation-next " aria-label="Next page: 数组"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book 个人笔记 -->
</html>
